<template>
  <dv-border-box-7 class="tech-table-card">
    <div class="tech-card-header">
      <span class="tech-title">最近创建的简历</span>
      <el-button 
        type="primary" 
        size="small" 
        class="tech-button tech-button--primary"
        @click="goToResumeManagement"
      >
        查看全部
      </el-button>
    </div>
    <div class="tech-table-container">
      <el-table 
        v-loading="loading"
        element-loading-text="数据加载中..."
          element-loading-background="rgba(0, 20, 40, 0.8)"
        :data="recentResumes" 
        style="width: 100%" 
        class="tech-table"
        :header-cell-style="{ background: 'rgba(0, 30, 60, 0.7)', color: '#00c0ff' }"
        :cell-style="{ background: 'rgba(0, 20, 40, 0.5)', color: '#ffffff' }"
      >
        <el-table-column prop="title" label="简历名称" />
        <el-table-column prop="username" label="用户姓名" />
        <el-table-column prop="templateName" label="使用模板" />
        <el-table-column label="创建时间">
          <template #default="scope">
            {{ formatDate(scope.row.createdAt) }}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </dv-border-box-7>
</template>

<script>
import { useRouter } from 'vue-router'

export default {
  name: 'RecentResumesTable',
  props: {
    loading: {
      type: Boolean,
      default: false
    },
    recentResumes: {
      type: Array,
      required: true
    }
  },
  setup() {
    const router = useRouter()
    
    // 格式化日期
    const formatDate = (dateString) => {
      if (!dateString) return ''
      const date = new Date(dateString)
      return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
    }
    
    // 跳转到简历管理页面
    const goToResumeManagement = () => {
      router.push('/resume')
    }
    
    return {
      formatDate,
      goToResumeManagement
    }
  }
}
</script>

<style scoped>
.tech-table-card {
  background-color: rgba(0, 20, 40, 0.7);
  padding: 15px;
}

.tech-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 0 10px;
}

.tech-title {
  font-size: 18px;
  font-weight: 600;
  color: #00c0ff;
  text-shadow: 0 0 10px rgba(0, 192, 255, 0.7);
}

.tech-table-container {
  margin-top: 15px;
}

.tech-table :deep(.el-table__header) {
  border: none;
}

.tech-table :deep(.el-table__body) {
  border: none;
}

.tech-table :deep(.el-table__row) {
  border-bottom: 1px solid rgba(0, 192, 255, 0.2);
}

.tech-button.tech-button--primary {
  background-color: rgba(0, 192, 255, 0.3);
  border-color: rgba(0, 192, 255, 0.8);
  color: #00c0ff;
}

.tech-button.tech-button--primary:hover {
  background-color: rgba(0, 192, 255, 0.5);
  box-shadow: 0 0 10px rgba(0, 192, 255, 0.7);
}
</style>